log using countering_abuse_log, replace

*********************************************************************************
***DOES ONLINE ABUSE OF POLITICIANS DECREASE CITIZENS' POLITICAL PARTICIPATION***
*********************************************************************************
****STATA 18*********************************************************************
*********************************************************************************

*Note, to execute correctly, this do-file requires the packages "estout", "coefplot" and "blindschemes" 
	* ssc install estout //Run this line if estout is not already installed (used when creating regression tables)
	* ssc install coefplot //Run this line if "Coefplot" is not already installed (used when plotting results in graphs)
	* ssc install blindschemes //Run this line if "blindschemes is not already installed (used to control graph layout) 

***Settings and data
	clear all
	set scheme plotplain
	graph set window fontface "Perpetua"
	cd "C:\Users\b059066\Documents\Filkassen\Digital Chikane af politikere\Artikler\Artikel 5, Countering online abuse through norms\Replication
	use "countering_abuse_data.dta"
	
*Adding label
label define agree 1 "Completely disagree" 2 "Disagree" 3 "Somewhat disagree" 4 "Neither/nor" 5 "Somewhat agree" 6 "Agree" 7 "Completely agree" 99 "Don't know"
label values tolerate write report agree

	* Descriptives
	graph hbar, over(tolerate) blabel(bar, format(%9.1f)) title("{it:Politicians should be}" "{it:able to tolerate such comments}") fxsize(44)
		graph save tolerate_hbar, replace
	graph hbar, over(write, axis(off)) blabel(bar, format(%9.1f)) title("{it:I would consider writing a comment}" "{it:to show my support for the politician}") fxsize(28)
		graph save write_hbar, replace
	graph hbar, over(report, axis(off)) blabel(bar, format(%9.1f)) title("{it:I would report this}" "{it:comment to Facebook}") fxsize(28)
		graph save report_hbar, replace
		
	graph combine  tolerate_hbar.gph write_hbar.gph report_hbar.gph, row(1) xcommon
		graph export hbar_dv.tif, replace
		erase tolerate_hbar.gph 
		erase write_hbar.gph 
		erase report_hbar.gph

*Creating indices
		*Conflict avoidance 
		tab1 ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset
		recode ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset (99=.)
		alpha ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset, item min(3) gen(uns_conflict_avoidance)
			//these lines standardize the measure to 0-1 and reverse the direction so high value is high conflict avoidance
			egen uns_conflict_avoidance_min=min(uns_conflict_avoidance) 
			egen uns_conflict_avoidance_max=max(uns_conflict_avoidance)
			gen conflict_avoidance=1-(uns_conflict_avoidance-uns_conflict_avoidance_min)/(uns_conflict_avoidance_max-uns_conflict_avoidance_min)
			drop uns_conflict_avoidance uns_conflict_avoidance_min uns_conflict_avoidance_max 
		tab conflict_avoidance
		
*Covariates measured are age, gender, education, political interest, conflict avoidance, and political trust.		
	recode pol_interest pol_trust tolerate write_comment report (99=.)	
	recode pol_interest pol_trust (0=0) (1=0.1) (2=0.2) (3=0.3) (4=0.4) (5=0.5) (6=0.6) (7=0.7) (8=0.8) (9=0.9) (10=1)


**************	
***Analyses***
**************
	
	*H1a: Exposure to information that highlights the personal consequences of abuse of politicians makes citizens less tolerant of such abuse. 
	*H2a: Exposure to information that highlights societal norms about abuse of politicians makes citizens less tolerant of such abuse.
	*H3a: Exposure to information that highlights the democratic consequences of abuse of politicians makes citizens less tolerant of such abuse.
	reg tolerate 		i.random_abuse_info age i.gender i.education_rec pol_interest conflict_avoidance pol_trust // no significant effects
		eststo tolerate
		margins i.random_abuse_info, post
		eststo mean_tol
		
		
	*H1b: Exposure to information that highlights the personal consequences of abuse of politicians makes citizens more likely to take action against such abuse.
	*H2b: Exposure to information that highlights societal norms about abuse of politicians makes citizens more likely to take action against such abuse.
	*H3b: Exposure to information that highlights the democratic consequences of abuse of politicians makes citizens more likely to take action against such abuse.
	reg write_comment 	i.random_abuse_info age i.gender i.education_rec pol_interest conflict_avoidance pol_trust // significant effects of all treatments
		eststo write
		margins i.random_abuse_info, post
		eststo mean_write
		estimates restore write
		margins, dydx(i.random_abuse_info)
		sum write_comment if random_abuse_info!=. & age!=. & gender!=. & education_rec!=. & pol_interest!=. & conflict_avoidance!=. & pol_trust!=. 
		local sd_write = `r(sd)'
		di _b[2.random_abuse_info] / `sd_write' 	// effect of "personal consequences" in SD 
		di _b[3.random_abuse_info] / `sd_write' 	// effect of "Societal norms" in SD
		di _b[4.random_abuse_info] / `sd_write' 	// effect of "Democratic consequences" in SD
		
		
	reg report			i.random_abuse_info age i.gender i.education_rec pol_interest conflict_avoidance pol_trust // significant effects of societal norms and democratic consequences
		eststo report
		margins i.random_abuse_info, post
		eststo mean_report
		estimates restore report
		margins, dydx(i.random_abuse_info)
		sum report if random_abuse_info!=. & age!=. & gender!=. & education_rec!=. & pol_interest!=. & conflict_avoidance!=. & pol_trust!=. 
		local sd_report = `r(sd)'
		di _b[2.random_abuse_info] / `sd_report' 	// effect of "personal consequences" in SD (NOTE: NOT SIGNIFICANT)
		di _b[3.random_abuse_info] / `sd_report' 	// effect of "Societal norms" in SD
		di _b[4.random_abuse_info] / `sd_report' 	// effect of "Democratic consequences" in SD
		
	
*************	
***Figures***
*************

	*Prereg
	coefplot 	tolerate, 	bylabel("Abuse tolerance") subtitle(, size(vlarge) nobox) || ///
				write, 		bylabel("Writing own comment") || ///
				report, 	bylabel("Reporting the comment") || ///
							, msymbol(circle) msize(large) mcolor(gs9) mlcolor(black) ciopts(recast(rspike) color(black)) keep(*.random_abuse_info) xline(0) xscale(r(-1 1)) byopts(row(1) iscale(1)) ///
							xsize(6) ysize(2) ylabel(,labsize(vlarge)) xlabel(,labsize(vlarge)) xlabel(-1(.5)1) 
				graph export effects_combined.tif, replace
			
	* Exploratory
		*gender
		reg tolerate		i.random_abuse_info##i.gender  age i.education_rec pol_interest conflict_avoidance pol_trust  // no significant interaction
							eststo reg_tolerate_gender
							margins, dydx(i.random_abuse_info) at(gender=(1)) post
							eststo tolerate_man
							estimates restore reg_tolerate_gender
							margins, dydx(i.random_abuse_info) at(gender=(2)) post
							eststo tolerate_woman
		reg write_comment	i.random_abuse_info##i.gender   age i.education_rec pol_interest conflict_avoidance pol_trust   // SIG - women react stronger to societal norms
							eststo reg_write_gender
							margins, dydx(i.random_abuse_info) at(gender=(1)) post 
							eststo write_man
							estimates restore reg_write_gender
							margins, dydx(i.random_abuse_info) at(gender=(2)) post 
							eststo write_woman
		reg report			i.random_abuse_info##i.gender   age i.education_rec pol_interest conflict_avoidance pol_trust   // SIG  - women react stronger to societal norms
							eststo reg_report_gender
							margins, dydx(i.random_abuse_info) at(gender=(1)) post 
							eststo report_man
							estimates restore reg_report_gender
							margins, dydx(i.random_abuse_info) at(gender=(2)) post 
							eststo report_woman
							
		coefplot 	(tolerate_man, mcolor(gs16) label("Men")) (tolerate_woman, mcolor(gs0) label(Women)), 	bylabel("Abuse tolerance") subtitle(, size(vlarge) nobox) || ///
					write_man write_woman, 											bylabel("Writing own comment") || ///
					report_man report_woman ,											bylabel("Report the comment") || ///
					, msymbol(circle) msize(medlarge) mlcolor(black) ciopts(recast(rspike) color(black)) xline(0) xscale(r(-1 1)) byopts(legend(pos(6) ) row(1) iscale(1)) ///
							xsize(6) ysize(2) ylabel(,labsize(vlarge)) xlabel(,labsize(vlarge)) xlabel(-1(.5)1) legend( size(vlarge))
					graph export effects_combined_gender.tif, replace
					
		
		estimates restore 	reg_tolerate_gender
		margins i.random_abuse_info, at(gender=(1 2)) pwcompare(groups)
		estimates restore reg_write_gender
		margins i.random_abuse_info, at(gender=(1 2)) pwcompare(groups)
		estimates restore reg_report_gender
		margins i.random_abuse_info, at(gender=(1 2)) pwcompare(groups)
	
	
************
***Tables***
************
esttab tolerate write report using reg_tab.rtf, noomitted se r2 b(2) se(2) label compress wide replace ///
		refcat(1.random_abuse_info "{\i Treatment:}" 1.gender "{\i Covariates:}" 1.education_rec "{\i Education:}", nolabel ) ///
		order(*.random_abuse_info *.gender age *.education_rec pol_interest conflict_avoidance pol_trust)
		
esttab reg_tolerate_gender reg_write_gender reg_report_gender using reg_int_tab.rtf, noomitted se r2 b(2) se(2) label compress wide replace ///
		refcat(1.random_abuse_info "{\i Treatment:}" 1.random_abuse_info#1.gender "{\i Interactions:}" 1.gender "{\i Covariates:}" 1.education_rec "{\i Education:}", nolabel )	///
		order(*.random_abuse_info *.random_abuse_info#*.gender age *.gender *.education_rec pol_interest conflict_avoidance pol_trust)


	
	
	
*************
***The End***
*************	
	
log close
	
	